<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__STATIC__/template/lib/html5shiv.js"></script>
    <script type="text/javascript" src="__STATIC__/template/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/template/static/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="__STATIC__/template/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <style>
        td{
            text-align:center; /*设置水平居中*/
            vertical-align:middle;/*设置垂直居中*/
        }
        /*分页样式*/
        .pagination{text-align:center;margin-top:20px;margin-bottom: 20px;}
        .pagination li{margin:0px 10px; border:1px solid #e6e6e6;padding: 3px 8px;display: inline-block;}
        .pagination .active{background-color: #46A3FF;color: #fff;}
        .pagination .disabled{color:#aaa;}
        a:hover{color: #ff081f; /*鼠标在a上面时,变蓝色*/}

    </style>
    <title>实战列表</title>
</head>
<body>

<div>
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span> 平台管理
        <span class="c-gray en">&gt;</span><span style="color:red;">平台邀请设置</span>
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
            <i class="Hui-iconfont">&#xe68f;</i>
        </a>
    </nav>
    <div class="page-container">

        <div class="mt-20">
            <table class="table table-border table-bordered table-bg table-hover">
                <thead>
                <tr class="text-c">
                    <th width="40"><input name="" type="checkbox" value=""></th>
                    <th width="40">ID</th>
                    <th width="150">名称</th>
                    <th width="100">邀请码</th>
                    <th width="100">邀请二维码</th>
                    <th width="200">操作</th>
                </tr>
                </thead>
                <tbody>
                
                <tr class="text-c va-m">
                    <td><input name="" type="checkbox" value="{$plat.id}"></td>
                    <td>{$plat.id?$plat.id:'1'}</td>

                    <td>
                        <input type="text" value="{$plat.name?$plat.name:''}" class="input-text" placeholder="平台名称" style="width:180px">
                        <span class="btn btn-success-outline radius size-S" onclick="setName(this,'{$plat.id}')">修改</span>
                    </td>
                    <td class="mark">
                        <input type="text" value="{$plat.mark?$plat.mark:''}" onchange="getMark(this,'{$plat.id}')" class="input-text" placeholder="生成邀请码" style="width:180px" >
                        <!--<span class="btn btn-success-outline radius size-MINI" onclick="mark(this,'{$plat.id}')" >
                            <i class="Hui-iconfont">&#xe68f;</i>
                        </span>-->
                    </td>
                   
                    <td>
                        {empty name='$plat.code_img'}
                        <span>暂无二维码</span>
                        {else /}
                        <img class="picture-thumb" src="__UPLOADS__/{$plat.code_img}">
                        {/empty}
                    </td>
                    <td class="td-manage">
                        {empty name='$plat.code_img'}
                        <a title="生成二维码" href="javascript:;" onclick="create(this,'{$plat.mark}','{$plat.id?$plat.id:"0"}')" class="ml-5 md-trigger" style="text-decoration:none">
                            <i class="Hui-iconfont">&#xe640;</i>生成二维码
                        </a>
                        {else /}
                        <span style="color: blue">已生成二维码</span>
                        {/empty}

                    </td>
                </tr>
               
                </tbody>
            </table>
        </div>
    </div>

</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__STATIC__/template/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/layer/2.4/layer.js"></script>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/template/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__STATIC__/template/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
    /* 生成二维码 */
    function create(obj,mark,id){
        layer.confirm('是否生成二维码？',function(){
            var url = "{:url('create')}";
            $.post(url,{ mark:mark,id:id},function(res){
                console.log(res);
                if(res.ok){
                    layer.msg(res.msg,{icon: 1,time:2000});
                    setTimeout("window.location.replace(location.href)",2000);
                }else{
                    layer.msg(res.msg,{icon: 5,time:2000});
                }

            })
        });
    }

    /* 修改邀请码*/
    function getMark(obj,id){
        //alert(1);
        layer.confirm('确认要生成邀请二维码吗？',function(index){
            var url = "{:url('admin/Plat/getMark')}";
            var mark = $(obj).val();
            $.post(url,{ id:id,mark:mark },function(res){
                console.log(res);
                if(res.ok) {
                    layer.msg(res.msg, {icon:1, time: 1000});
                    //  $(obj).val(mark);
                    setTimeout("window.location.replace(location.href)",1000);
                }else{
                    layer.msg(res.msg, {icon: 5, time: 1000});
                }
            })
        });

    }

    /* 生成邀请码 */
    function mark(obj,id){
        layer.confirm('是否生成邀请码？',function(){
            var url = "{:url('mark')}";
            $.post(url,{ id:id},function(res){
                console.log(res);
                if(res.ok){
                    layer.msg(res.msg,{icon: 1,time:2000});
                    setTimeout("window.location.replace(location.href)",2000);
                }else{
                    layer.msg(res.msg,{icon: 5,time:2000});
                }

            })
        })
    }
    /* 设置平台名称 */
    function setName(obj,id){
        var name = $(obj).prev('input').val();
      //  alert(name);
        layer.confirm('是否要设置平台名称？',function(){
            var url = "{:url('setName')}";
            $.post(url,{ name:name,id:id},function(res){
                console.log(res);
                if(res.ok){
                    layer.msg(res.msg,{icon: 1,time:2000});
                    setTimeout("window.location.replace(location.href)",2000);
                }else{
                    layer.msg(res.msg,{icon: 5,time:2000});
                }

            })
        })
    }



    /* 保存 */
    function authority_hold(obj,id){
        var code = $(obj).parent().parent().find('.code').find('input').val();
        var log_num = $(obj).parent().parent().find('.log_num').find('input').val();
        // alert(log_num);
        layer.confirm('确认要修改吗？',function(index){
            var url = "{:url('authority_hold')}";
            $.post(url,{ code:code,log_num:log_num,id:id },function(res){
                console.log(res);
                if(res.ok){
                    layer.msg(res.msg,{icon:1,time:1000});
                    $(obj).parent().parent().find('.code').find('input').val(res.code);
                    $(obj).parent().parent().find('.log_num').find('input').val(res.log_num);

                }else if(res.code==0){
                    layer.msg(res.msg,{icon:0,time:1000});
                }else{
                    layer.msg(res.msg,{icon:5,time:1000});
                }
            })
        });
    }
</script>
</body>
</html>